//
//  KoiAuthenticationCredential.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 14.04.25.
//

import Foundation
import Alamofire

struct KoiAuthenticationCredential : AuthenticationCredential {
    static let shared = KoiAuthenticationCredential()
    
    var accessToken: String {
        return KoiTokenStore.getAccessToken()
    }
    
    var refreshToken: String {
        return KoiTokenStore.getRefreshToken()
    }
    
    var exp: Double {
        return KoiTokenStore.getAccessTokenExp()
    }
    
    // 刷新的时间窗口，提前一天刷新
    var requiresRefresh: Bool {
        (Date().timeIntervalSince1970 + 60*60*24) > exp
    }
}
